Skip to content

feat(ohos): mobile native plugins, bridge facade adaptation, and permission request fallbacks - #25

Open
ljy9812 wants to merge 5 commits into
Eulogizethesun:ohdevfrom
ljy9812:ohdev-adjust
Open

feat(ohos): mobile native plugins, bridge facade adaptation, and permission request fallbacks#25
ljy9812 wants to merge 5 commits into
Eulogizethesun:ohdevfrom
ljy9812:ohdev-adjust

Conversation

@ljy9812

@ljy9812 ljy9812 commented Aug 22, 2026

Copy link
Copy Markdown

Changes

  • New OHOS ArkTS plugins: geolocation, barcode-scanner, biometric, haptics, nfc; notification registerListener/removeListener + action dispatch
  • geolocation watchPosition channel emit streaming; requestPermissions four-path settle fallback (requestPermissionsFromUser promise can hang on map-preview dialog) + polled permission read (selfPermissionStateChange fires before ATM commit)
  • barcode-scanner: same settle fallback pattern for CAMERA permission
  • bridge facade adaptation + OHOS cross-check enablement
  • OHOS adaptations for opener/clipboard/window-state/single-instance/process/notification; cfg isolation fixes
  • gate opener/window-state desktop-only APIs for mobile compile; fix window-state update_state freeze (skip sync is_minimized/is_maximized)

Impact

OHOS only; all ArkTS plugins live under openharmony/ per-plugin directories and Rust code is gated with cfg(target_env = "ohos"). Other platforms unchanged.

Testing

Verified on HUAWEI MateBook Pro (desktop form, API 23):

  • geolocation permission dialog grant path settles in ~3s with correct granted status; watchPosition emit streaming works
  • barcode-scanner CAMERA permission fallback, haptics, nfc, biometric covered by api example manual cases
  • cargo check clean for both the OHOS mobile target (OHOS_DEVICE_TYPE=mobile) and Windows native target
  • Local checklist review passed: 0 Blocker / 0 Major (5 Minor noted)

Related

Supersedes #22. Counterpart PRs: tauri#75, tao#21, wry#21, muda#5, tray-icon#9, openharmony-ability#46, window-vibrancy#3.

ljy9812 and others added 5 commits August 10, 2026 21:12
…is_maximized

Follow-up to the Resized/Moved freeze fix (59bf004). The CloseRequested
handler also calls update_state, which queries is_maximized()/is_minimized()
synchronously — the same NAPI is_window_minimized/is_window_maximized path
that blocks the main thread during a window transition. This caused autotest
tauri-apps#34 (CloseRequested fires) to time out (Timeout after 5000ms) when the close
hit a transition: close -> CloseRequested -> update_state -> is_minimized NAPI
blocks main thread -> next invoke (get_tracked_run_events) starved -> 5s timeout.

Fix: in update_state, cfg(target_env="ohos") skip is_maximized()/is_minimized()
(set false), non-OHOS byte-identical. The other update_state queries
(is_fullscreen/is_decorated/is_visible/inner_size/outer_position) are
non-blocking on OHOS (default values or cached window_rect), so only
is_minimized/is_maximized need gating. Tradeoff: window-state doesn't capture
the maximized/minimized flag on OHOS (was hanging anyway); size/position
restore unaffected.

Verified: tauri-apps#34 CloseRequested fires now passes (1614ms); autotest 247 PASS /
2 known FAIL (tauri-apps#33 Resumed, tauri-apps#85 clipboard) / 0 SKIP.

Co-Authored-By: Claude <noreply@anthropic.com>
…ission request fallbacks

- New OHOS ArkTS plugins: geolocation, barcode-scanner, biometric, haptics,
  nfc; notification registerListener/removeListener + action dispatch
- geolocation watchPosition channel emit streaming; requestPermissions
  four-path settle fallback (requestPermissionsFromUser promise can hang
  on map-preview dialog) + polled permission read
  (selfPermissionStateChange fires before ATM commit)
- barcode-scanner: same settle fallback pattern for CAMERA permission
- bridge facade adaptation + OHOS cross-check enablement
- OHOS adaptations for opener/clipboard/window-state/single-instance/
  process/notification; cfg isolation fixes
- gate opener/window-state desktop-only APIs for mobile compile; fix
  window-state update_state freeze (skip sync is_minimized/is_maximized)

Verified on device: geolocation permission dialog grant path settles in
~3s with correct granted status; watchPosition emit streaming works.

Co-Authored-By: Claude <noreply@anthropic.com>
The OHOS save branch previously skipped update_state() and only refreshed
position when StateFlags::POSITION was set, relying on event-driven caches
(stale on save races; Moved never fires on OHOS). Since tao's
inner_size()/outer_position() are non-blocking per-window cache reads
(only is_maximized/is_minimized block via sync NAPI — those stay skipped),
refresh both size and position for every tracked window before serializing.
serde serializes the whole WindowState struct, so SIZE-only saves also
persisted stale x/y — refreshing both fixes restore-to-(0,0).

Part of openspec change p1-window-state-per-window-rect (Phase 1+2, D7).

Co-Authored-By: Claude <noreply@anthropic.com>
… dispatcher round-trips

Two same-pattern AB deadlocks fixed (faultlogs 2026-08-25 x3 captured
both sides: tokio worker holds WindowStateCache lock -> window_getter!
rx.recv() waits on main thread, main thread in Resized/Moved handler
waits on the same lock -> permanent THREAD_BLOCK_6S):

- save_window_state: three phases — short lock snapshots tracked labels,
  fresh geometry (outer_position/inner_size) collected unlocked, short
  lock writes back + serializes, fs::write outside. Err/0x0 keeps the
  cached value (Option, old if-let semantics preserved).
- restore_state (p3): same discipline — unlocked fs::read of the saved
  state, short lock snapshot/default-seed, then all window operations
  (available_monitors/set_position/set_size/show/set_focus setters are
  fire-and-forget dispatches) outside the lock. Triggered by the default
  StateFlags::all() which includes POSITION — production default, while
  the old test only passed SIZE (coverage blind spot, now closed with an
  all-flags auto test in examples/api).

Non-OHOS paths are kept byte-for-byte under cfg(not(target_env="ohos")).
RestoringWindowState guard unchanged (handlers use try_lock).

Verified on device: full suite 282 pass / 1 fail (clipboard platform
limit) / 1 skip (haptics), all-flags restore via worker path 705ms no
appfreeze, zero new faultlogs.

Co-Authored-By: Claude <noreply@anthropic.com>
Remote-only commit is the pre-rebase push of work that was replayed
(and further refined) during the upstream-ohdev rebase; local content
is authoritative (-s ours). See upstream-ohdev-rebase-window-ops.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant